<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="hq">获取图书</button>
    <button class="tj">添加图书</button>
    <button class="sc">删除图书</button>
    <script src="./lib/axios.js"></script>
    <script>
        axios.defaults.baseURL = 'http://ajax-base-api-t.itheima.net'
        document.querySelector('.hq').onclick = () => {
            axios({
                method: 'get',
                url: '/api/getbooks',
            }).then(res => {
                console.log(res.data.data);
            })
        }
        document.querySelector('.tj').onclick = () => {
            axios({
                method: 'post',
                url: '/api/addbook',
                data: {
                    bookname: '刀剑神域',
                    author: '川原砾',
                    publisher: '天闻角川'
                }
            }).then(res => {
                console.log(res);
            })
        }
        document.querySelector('.sc').onclick = () => {
            axios({
                method: 'get',
                url: `/api/delbook`,
                params: {
                    id: 28
                }
            }).then(res => {
                console.log(res)
            })
        }
    </script>

</body>

</html>